home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / update1a / frmspell.frm (.txt) < prev    next >
Visual Basic Form  |  1999-07-26  |  6KB  |  200 lines

  1. VERSION 5.00
  2. Begin VB.Form frmSpell 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Dictionary"
  5.    ClientHeight    =   4776
  6.    ClientLeft      =   36
  7.    ClientTop       =   276
  8.    ClientWidth     =   5520
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   4776
  13.    ScaleWidth      =   5520
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin VB.CommandButton cmdAction 
  17.       Caption         =   "Lookup"
  18.       Height          =   432
  19.       Index           =   3
  20.       Left            =   4440
  21.       TabIndex        =   6
  22.       Top             =   3240
  23.       Width           =   972
  24.    End
  25.    Begin VB.CommandButton cmdAction 
  26.       Caption         =   "Anagarm"
  27.       Height          =   432
  28.       Index           =   2
  29.       Left            =   4440
  30.       TabIndex        =   5
  31.       Top             =   2400
  32.       Width           =   972
  33.    End
  34.    Begin VB.CommandButton cmdAction 
  35.       Caption         =   "Wildcard"
  36.       Height          =   432
  37.       Index           =   1
  38.       Left            =   4440
  39.       TabIndex        =   4
  40.       Top             =   1560
  41.       Width           =   972
  42.    End
  43.    Begin VB.CommandButton cmdAction 
  44.       Caption         =   "Spelling"
  45.       Height          =   432
  46.       Index           =   0
  47.       Left            =   4440
  48.       TabIndex        =   3
  49.       Top             =   720
  50.       Width           =   972
  51.    End
  52.    Begin VB.CommandButton cmdExit 
  53.       Caption         =   "Done"
  54.       Height          =   432
  55.       Left            =   4440
  56.       TabIndex        =   2
  57.       Top             =   4080
  58.       Width           =   972
  59.    End
  60.    Begin VB.ListBox lstDisplay 
  61.       Height          =   2736
  62.       Left            =   120
  63.       TabIndex        =   1
  64.       Top             =   600
  65.       Width           =   4212
  66.    End
  67.    Begin VB.ComboBox cboInput 
  68.       Height          =   288
  69.       Left            =   120
  70.       TabIndex        =   0
  71.       Top             =   120
  72.       Width           =   5292
  73.    End
  74. Attribute VB_Name = "frmSpell"
  75. Attribute VB_GlobalNameSpace = False
  76. Attribute VB_Creatable = False
  77. Attribute VB_PredeclaredId = True
  78. Attribute VB_Exposed = False
  79.    Option Explicit
  80.    Const HeightLimit = 5000
  81.    Const WidthLimit = 5640
  82.    Dim objMsWord As Word.Application
  83.    Dim SugList As SpellingSuggestions
  84.    Dim sug As SpellingSuggestion
  85.    Dim synInfo As SynonymInfo
  86.    Dim synList As Variant
  87.    Dim AntList As Variant
  88.    Private Sub cmdAction_Click(Index As Integer)
  89.        Dim strTemp As String
  90.        Dim blnRet As Boolean
  91.        Dim iCount As Integer
  92.         
  93.        On Error GoTo eh_Trap:
  94.        If cboInput.List(0) <> cboInput Then
  95.            cboInput.AddItem cboInput, 0
  96.        End If
  97.        Set objMsWord = New Word.Application
  98.        
  99.        objMsWord.WordBasic.FileNew 'open a doc
  100.        objMsWord.Visible = False 'hide the doc
  101.        lstDisplay.Clear
  102.        
  103.       
  104.        Select Case Index
  105.            Case 0
  106.          blnRet = objMsWord.CheckSpelling(cboInput)
  107.            If blnRet = True Then
  108.                lstDisplay.AddItem "OK"
  109.            Else
  110.                Set SugList = objMsWord.GetSpellingSuggestions(cboInput, _
  111.                SuggestionMode:=wdSpelling)
  112.                
  113.                If SugList.Count = 0 Then
  114.                    lstDisplay.AddItem "No suggestions"
  115.                Else
  116.                    For Each sug In SugList
  117.                        lstDisplay.AddItem sug.Name
  118.                    Next sug
  119.                End If
  120.                
  121.            End If
  122.            Case 1
  123.            Set SugList = objMsWord.Application.GetSpellingSuggestions(cboInput, _
  124.            SuggestionMode:=wdWildcard)
  125.            If SugList.Count = 0 Then
  126.                lstDisplay.AddItem "No suggestions"
  127.            Else
  128.                For Each sug In SugList
  129.                    lstDisplay.AddItem sug.Name
  130.                Next sug
  131.                
  132.            End If
  133.            Case 2
  134.         Set SugList = objMsWord.GetSpellingSuggestions(cboInput, _
  135.            SuggestionMode:=wdAnagram)
  136.            If SugList.Count = 0 Then
  137.                lstDisplay.AddItem "No suggestions"
  138.            Else
  139.                For Each sug In SugList
  140.                    lstDisplay.AddItem sug.Name
  141.                Next sug
  142.            End If
  143.            Case 3
  144.                    Set synInfo = objMsWord.SynonymInfo(cboInput)
  145.            lstDisplay.AddItem "*** MEANING ***"
  146.            
  147.            If synInfo.MeaningCount >= 2 Then
  148.                synList = synInfo.MeaningList
  149.                For iCount = 1 To UBound(synList)
  150.                    lstDisplay.AddItem synList(iCount)
  151.                Next iCount
  152.            Else
  153.                lstDisplay.AddItem "None"
  154.            End If
  155.            lstDisplay.AddItem "*** SYNONYM ***"
  156.            If synInfo.MeaningCount >= 2 Then
  157.                synList = synInfo.SynonymList(2)
  158.                For iCount = 1 To UBound(synList)
  159.                    lstDisplay.AddItem synList(iCount)
  160.                Next iCount
  161.            Else
  162.                lstDisplay.AddItem "None"
  163.            End If
  164.            Set synInfo = Nothing
  165.        End Select
  166. eh_exit:
  167.    objMsWord.Quit
  168.    Set objMsWord = Nothing
  169.    cboInput.SetFocus
  170.    Exit Sub
  171. eh_Trap:
  172.    lstDisplay.AddItem Err & vbTab & Error$
  173.    Resume eh_exit:
  174.    End Sub
  175.    Private Sub cmdExit_Click()
  176.        Unload Me
  177.    End Sub
  178.    Private Sub Form_Load()
  179.        cboInput.Clear
  180.        
  181.    End Sub
  182.    Private Sub Form_Resize()
  183.        Select Case Me.WindowState
  184.            Case vbNormal
  185.            If Me.Height < HeightLimit Then
  186.                Me.Height = HeightLimit
  187.            End If
  188.            lstDisplay.Height = Me.Height - 1000
  189.            Me.Width = WidthLimit
  190.            Case Else
  191.        End Select
  192.    End Sub
  193.    Private Sub lstDisplay_DblClick()
  194.        cboInput.AddItem lstDisplay, 0
  195.        cboInput.ListIndex = 0
  196.        lstDisplay.Clear
  197.        cboInput.SetFocus
  198.        
  199.    End Sub
  200.